package com.onenine.app.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.onenine.app.R;
import com.onenine.app.utils.RoleResLoader;
import com.onenine.common.util.SizeUtils;

/**
 * 创建时间：2018/7/19 0019 17:03
 * 创建人：fly
 * 功能描述：融云连接状态条
 */
public class RcConnectStatusBar extends LinearLayout {

    private TextView tvStatusMsg;

    public RcConnectStatusBar(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initialize(context);
    }

    private void initialize(Context context) {
        inflate(context, R.layout.layout_rc_connect_status_bar, this);
        setOrientation(LinearLayout.HORIZONTAL);
        setBackgroundColor(RoleResLoader
                .getRoleDrawableResourceId(RoleResLoader.DynamicResName.THEME_COLOR));
        int padding = getResources().getDimensionPixelOffset(R.dimen.dp10);
        setPadding(padding, padding, padding, padding);
        setMinimumHeight(SizeUtils.dp2px(48));
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        tvStatusMsg = findViewById(R.id.tv_status_message);
    }

    public RcConnectStatusBar setVisible(boolean visible) {
        setVisibility(visible ? View.VISIBLE : View.GONE);
        return this;
    }

    public RcConnectStatusBar showStatusMsg(String statusMsg) {
        tvStatusMsg.setText(statusMsg);
        return this;
    }

}
